<template>
  <div class="newsInfo">
    <h3 class="title">{{ newsInfo.title }}</h3>
    <!-- 子标题 -->
    <p class="subtitle">
      <span>发表时间：{{ newsInfo.add_time | dateFormat }}</span>
      <span>点击：{{ newsInfo.click }}次</span>
    </p>
    <!-- 内容区域 -->
    <div class="content" v-html="newsInfo.content"></div>
    <!-- 评论区域 -->
    <comment :id="this.id"></comment>
  </div>
</template>
<script>
import comment from '@/component/comment'
export default {
  data () {
    return {
      id: this.$route.params.id,
      newsInfo: {}
    }
  },
  created () {
    this.getNewsInfo()
  },
  methods: {
    getNewsInfo () {
      this.axios.get(`http://www.lovegf.cn:8899/api/getnew/${this.id}`).then(res => {
        if (res.status === 200) {
          console.log(res)
          this.newsInfo = res.data.message[0]
        }
      })
    }
  },
  components: {
    comment
  }
}
</script>
<style scoped>
.newsInfo {
  padding: 0 4px;
}
.newsInfo .title {
  font-size: 16px;
  text-align: center;
  margin: 15px 0;
  color: red;
}
.newsInfo .subtitle {
  font-size: 13px;
  color: #226aff;
  display: flex;
  justify-content: space-between;
}
.newsInfo .content img {
  width: 100%;
}
</style>
